package com.sjtu.vfact.textual.tablemodel;

import java.util.Map;
import java.util.Set;

public class UncoveredTermsTableModel extends VFactTableModel{

	private static final long serialVersionUID = -8337049429940931791L;

//	public static final int COL_NO = 0;
	public static final int COL_UNCOVERED_TERMS = 0;
	public static final int COL_DOCIDS = 1;
	public static final int COL_SUPPORT = 2;
	
//	public static final int COL_NO_WIDTH = 10;
	public static final int COL_UNCOVERED_TERMS_WIDTH = 150;
	public static final int COL_DOCIDS_WIDTH = 150;
	public static final int COL_SUPPORT_WIDTH = 30;
	
	public UncoveredTermsTableModel() {
		super();
		setColumnNames(new String[]{"Uncovered Terms", "DocIDs", "Support"});
	}
	
	public void initializeTableModel(Map<String, Set<Integer>> uncoveredTerms){
		clearTable();
		
		Object[] tuple = null;
		if(uncoveredTerms != null){
//			int no = 1;
			for(Map.Entry<String, Set<Integer>> entry : uncoveredTerms.entrySet()){
				tuple = new Object[getColumnCount()]; 
				String term = entry.getKey();
				Set<Integer> docIDs = entry.getValue();
//				tuple[COL_NO] = no;
				tuple[COL_UNCOVERED_TERMS] = term;
				tuple[COL_DOCIDS] = docIDs;
				tuple[COL_SUPPORT] = docIDs.size();
				addRow(tuple);
//				no++;
			}
		}
		
	}
	
}
